﻿namespace BuzzX8.Xmpp.StreamElements.Builders
{
    public abstract class DatagramElementBuilder<T> : CompositeElementBuilder<T> where T : DatagramElement
    {
        protected override void AddAttributeToRootElement(string name, string value)
        {
            switch (name)
            {
                case "id":
                    RootElement.Id = value;
                    break;

                case "from":
                    RootElement.From = JID.Parse(value);
                    break;

                case "to":
                    RootElement.To = JID.Parse(value);
                    break;

                case "xml:lang":
                    RootElement.XmlLang = value;
                    break;

                default:
                    base.AddAttributeToRootElement(name, value);
                    break;
            }
        }
    }
}
